<!DOCTYPE>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>浮动广告</title>
  <script type="text/javascript">
    var delta=0.15
    var layers;
    function floaters() {
      this.items= [];
      this.addItem= function(id,x,y,content){
        document.write('<div id='+id+' style="z-index: 10; position: absolute;  width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</div>');
        var newItem= {};
        newItem.object= document.getElementById(id);
        if(y>10) {y=0}
        newItem.x= x;
        newItem.y= y;
        this.items[this.items.length]= newItem;
      }
      this.play= function(){
        layers= this.items
        setInterval('play()',10);
      }
    }
    function play(){
      for(var i=0;i<layers.length;i++){
        var obj= layers[i].object;
        var obj_x= (typeof(layers[i].x)=='string'?eval(layers[i].x):layers[i].x);
        var obj_y= (typeof(layers[i].y)=='string'?eval(layers[i].y):layers[i].y);
        if(obj.offsetLeft!=(document.body.scrollLeft+obj_x)) {
          var dx=(document.body.scrollLeft+obj_x-obj.offsetLeft)*delta;
          dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
          obj.style.left=obj.offsetLeft+dx;
        }
        if(obj.offsetTop!=(document.body.scrollTop+obj_y)) {
          var dy=(document.body.scrollTop+obj_y-obj.offsetTop)*delta;
          dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
          obj.style.top=obj.offsetTop+dy;
        }
        obj.style.display= '';
      }
    }

    var strfloat = new floaters();
    strfloat.addItem("followDiv",6,80,"<img src='ad.jpg'  border='0'>");
    strfloat.play();
  </script>
</head>
<body style="width: 1000px;height: 1000px;">
</body>

</html>